package com.xiaobo.client;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;

public class SystemSet extends Activity {
	Dialog dialog = null;
	private final static int DIALOG = 1;
	boolean[] flags = new boolean[] { false, false, false };// 初始复选情况
	String[] items = null;

	Context thiscc;


	public void ShowDialog(Context cc){
		thiscc=cc;
		items = getResources().getStringArray(R.array.hobby);		
		showDialog(DIALOG);	
	}
	@Override
	public Dialog onCreateDialog(int id) {
		switch (id) {
		case DIALOG:
			Builder builder = new Builder(thiscc);
			// 设置对话框的图标 builder.setIcon(R.drawable.header);
			// 设置对话框的标题 builder.setTitle("复选框对话框");
			builder.setMultiChoiceItems(R.array.hobby, flags,
					new DialogInterface.OnMultiChoiceClickListener() {
						public void onClick(DialogInterface dialog, int which,
								boolean isChecked) {
							flags[which] = isChecked;
							String result = "您选择了：";
							for (int i = 0; i < flags.length; i++) {
								if (flags[i]) {
									result = result + items[i] + "、";
								}
							}
							// editText.setText(result.substring(0,
							// result.length()-1));
						}
					});
			// 添加一个确定按钮
			builder.setPositiveButton(" 确 定 ",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {

						}
					});
			// 创建一个复选框对话框
			dialog = builder.create();
			break;
		}
		return dialog;
	}

}
